cd "${data}"

*reported voter turnout with 2015 BES

use "bes_f2f_2015_v4.0.dta", clear 

 
 keep e01 l09 j01 p03_1 t02 h01 g01_1 turnoutValidationReg validatedTurnoutBinary b01 Age education y01 y09
 
 gen voted_r = .
 replace voted_r = 1 if b01 == 1
 replace voted_r = 0 if b01 == 2

 gen voted_v = validatedTurnoutBinary
 
 gen lr = e01
 replace lr = . if e01==-2 | e01==-1
 
 gen redist = l09 
 replace redist = . if l09==-1 
 
 gen immigration = j01
 recode immigration (1=7) (2=6) (3=5) (6=2) (7=1)
 replace immigration = . if j01==-1
 
 gen eu = p03_1
 replace eu = . if p03_1==-1
 
 gen laworder = t02
 recode laworder (0=10) (1=9) (2=8) (3=7) (4=6) (7=3) (8=2) (9=1) (10=0)
 replace laworder = . if t02==-1
 
 gen environment = h01
 replace environment = . if h01==-1
  recode environment (0=10) (1=9) (2=8) (3=7) (4=6) (7=3) (8=2) (9=1) (10=0)

 gen spending = g01_1
 recode spending (0=10) (1=9) (2=8) (3=7) (4=6) (7=3) (8=2) (9=1) (10=0)
 replace spending = . if g01_1==-1
 
 
 gen age = Age 
 replace age = . if age==-1
 
 gen education_ = 0
 replace education_ = 1 if education==1 | education==2 | education==3 
 
 gen income = .
 replace income = 0 if y01==1 | y01==2 | y01==3 | y01==4
 replace income = 1 if y01==5 | y01==6 | y01==7 | y01==8
 replace income = 2 if y01==9 | y01==10 | y01==11 | y01==12 
 replace income = 3 if y01==13 | y01==14 | y01==15 

 gen gender = .
 replace gender = 0 if y09==1
 replace gender = 1 if y09==2
 
 keep voted_r voted_v lr redist immigration eu laworder environment spending age education income gender
 
 
 drop if age==.
 drop if education==.
 drop if gender==.
 drop if income==.
 drop if voted_v==.
 drop if voted_r==.
  

  eststo m1_r0: regress lr voted_r , robust  
  eststo m1_v0: regress lr voted_v , robust 
 
  eststo m2_r0: regress redist voted_r , robust
  eststo m2_v0: regress redist voted_v , robust
 
  eststo m3_r0: regress spending voted_r , robust 
  eststo m3_v0: regress spending voted_v , robust 
  
  eststo m4_r0: regress immigration voted_r , robust
  eststo m4_v0: regress immigration voted_v , robust
 
  eststo m5_r0: regress environment voted_r , robust 
  eststo m5_v0: regress environment voted_v , robust 
  
  eststo m6_r0: regress laworder voted_r , robust
  eststo m6_v0: regress laworder voted_v , robust 
 
  eststo m7_r0: regress eu voted_r , robust
  eststo m7_v0: regress eu voted_v , robust

  
  *TABLE M.1: REPORTED TURNOUT 
  

 esttab m1_r0  m2_r0  m3_r0  m4_r0  m5_r0  m6_r0  m7_r0  using ${tables}/Table5a.tex, replace ///
 b(3) se(2) 
 
   *TABLE M.2: VALIDATED TURNOUT 

  esttab  m1_v0  m2_v0  m3_v0  m4_v0  m5_v0  m6_v0  m7_v0 using ${tables}/Table5b.tex, replace ///
 b(3) se(2) 
 
 *FIGURE M.3: REPORTED TURNOUT AND VALIDATED TURNOUT IN THE BRITISH PUBLIC IN 2015
 
 coefplot  ///
 (m1_r0, keep(voted_r) label(bivariate) msymbol(circle_hollow) mcolor(gs5%50) ciopts(color(gs5%50))) ///
 (m1_v0, keep(voted_v) label() mcolor(gs5) ciopts(color(gs5))) ///
 (m2_r0, keep(voted_r) label() msymbol(circle_hollow) mcolor(gs5) ciopts(color(gs5))) ///
 (m2_v0, keep(voted_v) label() mcolor(gs5) ciopts(color(gs5))) ///
 (m3_r0, keep(voted_r) label() msymbol(circle_hollow) mcolor(gs5) ciopts(color(gs5))) ///
 (m3_v0, keep(voted_v) label() mcolor(gs5) ciopts(color(gs5))) ///
 (m4_r0, keep(voted_r) label() msymbol(circle_hollow) mcolor(gs5) ciopts(color(gs5))) ///
 (m4_v0, keep(voted_v) label() mcolor(gs5) ciopts(color(gs5))) ///
 (m5_r0, keep(voted_r) label() msymbol(circle_hollow) mcolor(gs5) ciopts(color(gs5))) ///
 (m5_v0, keep(voted_v) label() mcolor(gs5) ciopts(color(gs5))) ///
 (m6_r0, keep(voted_r) label() msymbol(circle_hollow) mcolor(gs5) ciopts(color(gs5))) ///
 (m6_v0, keep(voted_v) label() mcolor(gs5) ciopts(color(gs5))) ///
 (m7_r0, keep(voted_r) label() msymbol(circle_hollow) mcolor(gs5) ciopts(color(gs5))) ///
 (m7_v0, keep(voted_v) label() mcolor(gs5) ciopts(color(gs5))) ///
 , horizontal xline(0, lcolor(gs5)) ///
   bylabel(no controls) byopts(legend(off)) ///
   ytitle("") ///
   coeflabels(voted = "") ///
   ylabel(0.58 "leftright" 0.71 "redistribution" 0.84 "spending" 0.98 "immigration" 1.11 "environment" 1.24 "civil liberties" 1.37 "EU integration" ///
          1.64 "leftright" 1.77 "redistribution" 1.90 "spending" 2.03 "immigration" 2.16 "environment" 2.30 "civil liberties" 2.43 "EU integration") ///
   xlab(, nogrid) legend(off)
graph save "${figures}/FigureM3.gph", replace 
graph export "${figures}/FigureM3.png", as(png) replace

 

  * descriptives 
 
egen lr_voter_r = mean(lr) if voted_r==1
egen lr_nonvoter_r = mean(lr) if voted_r==0
label variable lr_voter_r "voter"
egen lr_voter_v = mean(lr) if voted_v==1
egen lr_nonvoter_v = mean(lr) if voted_v==0
label variable lr_nonvoter_r "non-voter"

egen redist_voter_r = mean(redist) if voted_r==1
egen redist_nonvoter_r = mean(redist) if voted_r==0
 
egen redist_voter_v = mean(redist) if voted_v==1
egen redist_nonvoter_v = mean(redist) if voted_v==0

egen spending_voter_r = mean(spending) if voted_r==1
egen spending_nonvoter_r = mean(spending) if voted_r==0
 
egen spending_voter_v = mean(spending) if voted_v==1
egen spending_nonvoter_v = mean(spending) if voted_v==0

egen immigration_voter_r = mean(immigration) if voted_r==1
egen immigration_nonvoter_r = mean(immigration) if voted_r==0
 
egen immigration_voter_v = mean(immigration) if voted_v==1
egen immigration_nonvoter_v = mean(immigration) if voted_v==0

egen laworder_voter_r = mean(laworder) if voted_r==1
egen laworder_nonvoter_r = mean(laworder) if voted_r==0
 
egen laworder_voter_v = mean(laworder) if voted_v==1
egen laworder_nonvoter_v = mean(laworder) if voted_v==0

egen eu_voter_r = mean(eu) if voted_r==1
egen eu_nonvoter_r = mean(eu) if voted_r==0
 
egen eu_voter_v = mean(eu) if voted_v==1
egen eu_nonvoter_v = mean(eu) if voted_v==0

egen environment_voter_r = mean(environment) if voted_r==1
egen environment_nonvoter_r = mean(environment) if voted_r==0
 
egen environment_voter_v = mean(environment) if voted_v==1
egen environment_nonvoter_v = mean(environment) if voted_v==0

 
 graph bar lr_voter_r lr_nonvoter_r, bar(1, color(black%70)) bar(2, color(black%30)) ylab(0(2)8, nogrid) yline(5, lcolor(gs7%50) lpattern(dash)) legend(off) title(leftright)
 graph save "${data}/BES2015/1a.gph", replace 
 
 graph bar lr_voter_v lr_nonvoter_v, bar(1, color(black%70)) bar(2, color(black%30)) ylab(0(2)8, nogrid) yline(5, lcolor(gs7%50) lpattern(dash)) legend(off) title(leftright)
 graph save "${data}/BES2015/1b.gph", replace 
 
 graph bar redist_voter_r redist_nonvoter_r, bar(1, color(black%70)) bar(2, color(black%30)) ylab(0(2)8, nogrid) yline(5, lcolor(gs7%50) lpattern(dash)) legend(off) title(redistribution)
  graph save "${data}/BES2015/2a.gph", replace 
  
 graph bar redist_voter_v redist_nonvoter_v, bar(1, color(black%70)) bar(2, color(black%30)) ylab(0(2)8, nogrid) yline(5, lcolor(gs7%50) lpattern(dash)) legend(off) title(redistribution)
  graph save "${data}/BES2015/2b.gph", replace 
  
  graph bar spending_voter_r redist_nonvoter_r, bar(1, color(black%70)) bar(2, color(black%30)) ylab(0(2)8, nogrid) yline(5, lcolor(gs7%50) lpattern(dash)) legend(off) title(spending)
   graph save "${data}/BES2015/3a.gph", replace 
   
 graph bar spending_voter_v redist_nonvoter_v, bar(1, color(black%70)) bar(2, color(black%30)) ylab(0(2)8, nogrid) yline(5, lcolor(gs7%50) lpattern(dash)) legend(off) title(spending)
  graph save "${data}/BES2015/3b.gph", replace 
 
   graph bar immigration_voter_r redist_nonvoter_r, bar(1, color(black%70)) bar(2, color(black%30)) ylab(0(2)8, nogrid) yline(5, lcolor(gs7%50) lpattern(dash)) legend(off) title(immigration)
    graph save "${data}/BES2015/4a.gph", replace 
	
 graph bar immigration_voter_v redist_nonvoter_v, bar(1, color(black%70)) bar(2, color(black%30)) ylab(0(2)8, nogrid) yline(5, lcolor(gs7%50) lpattern(dash)) legend(off) title(immigration)
  graph save "${data}/BES2015/4b.gph", replace 
  
    graph bar laworder_voter_r redist_nonvoter_r, bar(1, color(black%70)) bar(2, color(black%30)) ylab(0(2)8, nogrid) yline(5, lcolor(gs7%50) lpattern(dash)) legend(off) title(civil liberties)
	 graph save "${data}/BES2015/5a.gph", replace 
	 
 graph bar laworder_voter_v redist_nonvoter_v, bar(1, color(black%70)) bar(2, color(black%30)) ylab(0(2)8, nogrid) yline(5, lcolor(gs7%50) lpattern(dash)) legend(off) title(civil liberties)
  graph save "${data}/BES2015/5b.gph", replace 
  
     graph bar environment_voter_r redist_nonvoter_r, bar(1, color(black%70)) bar(2, color(black%30)) ylab(0(2)8, nogrid) yline(5, lcolor(gs7%50) lpattern(dash)) legend(off) title(environment)
	  graph save "${data}/BES2015/6a.gph", replace 
	  
 graph bar eu_voter_v redist_nonvoter_v, bar(1, color(black%70)) bar(2, color(black%30)) ylab(0(2)8, nogrid) yline(5, lcolor(gs7%50) lpattern(dash)) legend(off) title(environment)
  graph save "${data}/BES2015/6b.gph", replace 
 
     graph bar environment_voter_r redist_nonvoter_r, bar(1, color(black%70)) bar(2, color(black%30)) ylab(0(2)8, nogrid) yline(5, lcolor(gs7%50) lpattern(dash)) legend(off) title(EU integration)
	  graph save "${data}/BES2015/7a.gph", replace 
	  
 graph bar eu_voter_v redist_nonvoter_v, bar(1, color(black%70)) bar(2, color(black%30)) ylab(0(2)8, nogrid) yline(5, lcolor(gs7%50) lpattern(dash)) legend(off) title(EU integration)
  graph save "${data}/BES2015/7b.gph", replace 
 
 * FIGURE M.1: MEAN POSITION BASED ON REPORTED TURNOUT AMONG VOTERS AND NON-VOTERS
 cd "${data}/BES2015"
 graph combine 1a.gph 2a.gph 3a.gph 4a.gph 5a.gph 6a.gph 7a.gph , title(Reported Turnout) 
  graph save "${figures}/reported.gph", replace 
  graph export "${figures}/reported.png", as(png) replace

 
  
 * FIGURE M.2: MEAN POSITION BASED ON VALIDATED TURNOUT AMONG VOTERS AND NON-VOTERS
 cd "${data}/BES2015"
 graph combine 1b.gph 2b.gph 3b.gph 4b.gph 5b.gph 6b.gph 7b.gph , title(Validated Turnout) 
  graph save "${figures}/validated.gph", replace 
  graph export "${figures}/validated.png", as(png) replace
